$("#loginBtn").click(function(){
    var user = $("#username").val();
    var pass = $("#password").val();
    $.post("LoginServlet",{username:user, password:pass},function(res){
        var data = JSON.parse(res);
        if(data.code === "1"){
            if(data.name){
                localStorage.setItem("name",data.name);
                window.location.href='home.html';
            }
        }else{
            alert("账号或密码错误！");
        }
      });
    
})